package com.usian.skill.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.injector.methods.SelectList;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.usian.skill.mapper.GoodsMapper;
import com.usian.skill.pojo.Goods;
import com.usian.skill.service.GoodsService;
import com.usian.skill.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
    @Resource
    private GoodsMapper goodsMapper;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public List<GoodsVo> qclist() {
        List<GoodsVo> goodsVos = JSON.parseArray(stringRedisTemplate.opsForValue().get("goods"), GoodsVo.class);
        return goodsVos;
    }



    @Override
    public GoodsVo getgoodsvobyid(Long id) {
        GoodsVo vo = JSON.parseObject(stringRedisTemplate.opsForValue().get(id + ""), GoodsVo.class);
        return vo;
    }

    @Override
    public List<GoodsVo> qclistDB() {
        return goodsMapper.qclist();
    }

    @Override
    public GoodsVo getgoodsvobyidDB(Long goodsId) {
        return goodsMapper.huixian(goodsId);
    }
}
